package proxy;

/**
 * 对所有实现了Movable接口的对象去做代理。
 */
interface Movable{
    void move();
}

/**
 * Tank
 */
class Tank implements Movable{
    @Override
    public void move() {
        System.out.println("calcal");
    }
}

/**
 * 日志
 */
class MovableLogProxy implements Movable{
    Movable movable;
    public MovableLogProxy(Movable movable){
        this.movable = movable;
    }

    @Override
    public void move() {
        System.out.println("log");
        movable.move();
    }
}

/**
 * 时间
 */
class MovableTimeProxy implements Movable{
    Movable movable;
    public MovableTimeProxy(Movable movable){
        this.movable = movable;
    }

    @Override
    public void move() {
        System.out.println("time");
        movable.move();
    }
}

/**
 * Proxy
 */
public class Proxy {
    public static void main(String[] args) {
        System.out.println("Proxy");

        new MovableTimeProxy(new MovableLogProxy(new Tank())).move();
    }
}
